package com.xjm.i1.core.struct.node.write;

import cn.hutool.core.util.NumberUtil;
import com.xjm.i1.constant.ColorEnum;
import com.xjm.i1.utils.StrUtils;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 导出Excel数据中色差与密度的数据结构
 **/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class ExcelDiffDensity extends AbstractExcelCollection {

    /*@ExcelIgnore
    private MinDensityEnum densitySign;*/

    private double valueULL;

    private double valueULA;

    private double valueULB;

    private double valueULDensity;

    private double valueURL;

    private double valueURA;

    private double valueURB;

    private double valueURDensity;

    private double valueML;

    private double valueMA;

    private double valueMB;

    private double valueMDensity;

    private double valueDLL;

    private double valueDLA;

    private double valueDLB;

    private double valueDLDensity;

    private double valueDRL;

    private double valueDRA;

    private double valueDRB;

    private double valueDRDensity;

    private double formulaULLAB;

    private double formulaURLAB;

    private double formulaDLLAB;

    private double formulaDRLAB;

    private double formulaMLAB;

    private double formulaLABAVG;

    private double formulaDensityAVG;

    private double formulaDensitySingle;

    private String formulaDensitySinglePercent;

    public ExcelDiffDensity(String deviceId, String env, String pageId, ColorEnum color) {
        super(deviceId, env, pageId, color);
    }

    public double calculateDensityAVG() {
        return (this.valueULDensity + this.valueDLDensity +this.valueMDensity + this.valueURDensity + this.valueDRDensity)/5.0D;
    }

    public double calculateDensitySingle() {
        return NumberUtil.max(this.valueULDensity, this.valueDLDensity, this.valueMDensity, this.valueURDensity, this.valueDRDensity)
                - NumberUtil.min(this.valueULDensity, this.valueDLDensity, this.valueMDensity, this.valueURDensity, this.valueDRDensity);
    }

    public String calculateDensitySinglePercent() {
        double doubleVal = this.calculateDensitySingle()
                / NumberUtil.max(this.valueULDensity, this.valueDLDensity, this.valueMDensity, this.valueURDensity, this.valueDRDensity);
        return StrUtils.covertPercent(doubleVal);
    }

    public double calculateLABAVG() {
        return NumberUtil.round(
                (this.formulaDRLAB + this.formulaDLLAB + this.formulaULLAB + this.formulaMLAB + this.formulaURLAB)/5.0D
                , 2).doubleValue();
    }
}
